<template>
    <div>
<h1>修改</h1>
<table class="table">
    <tbody>
        <tr>
            <td>商铺名称</td>
            <td>
                <input type="text" v-model="data.shopName">
            </td>
        </tr>
        <tr>
            <td>商铺楼层</td>
            <td>
                <select v-model="data.lc">
                    <option value="">请选择楼层</option>
                    <option value="1楼">1楼</option>
                    <option value="2楼">2楼</option>
                    <option value="3楼">3楼</option>
                    <option value="4楼">4楼</option>
                    <option value="5楼">5楼</option>
                    <option value="6楼">6楼</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>商铺编号</td>
            <td>
                <input type="text" v-model="data.shopId">
            </td>
        </tr>
        <tr>
            <td>室内面积</td>
            <td>
                <input type="text" v-model="data.roomMj">
            </td>
        </tr>
        <tr>
            <td>租金</td>
            <td>
                <input type="number" v-model="data.proce">
            </td>
        </tr>
         <tr>
            <td>联系方式</td>
            <td>
                <input type="text" v-model="data.phone">
            </td>
        </tr>
        <tr>
            <td>商铺状态</td>
            <td>
                <select v-model="data.stateId">
    <option value="0">请选择</option>
    <option v-for="d in Scope" :value="d.stateId">{{d.stateName}}</option>
</select>
            </td>
        </tr>
        <tr>
            <td>备注</td>
            <td>
                <textarea v-model="data.maggess"></textarea>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="修改" class="btn btn-success" @click="Updaes">
            </td>
        </tr>
    </tbody>
</table>


    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
const rout=useRouter();
const router=useRoute();
onMounted(()=>{
    Fts();
    GetScope();
})

const Scope=ref([{
    "stateId": 0,
    "stateName": ""
}])
const GetScope=()=>{
    axios.get("/api/State/GetState",{params:Scope.value}).then(res=>{
        Scope.value=res.data;
    })
}

const data=ref({
      "sid": 3,
  "shopName": "A-15-3",
  "lc": "",
  "bossName": "李添新",
  "phone": "14483948596",
  "roomMj": "19.88平方米",
  "proce": 1300,
  "stateId": 1,
  "qzDate": null,
  "shopId": "10000002",
  "maggess": null,
  "isDel": false,
  "delDate": null
})

const Fts=()=>{
    var mid=router.query.id;
    axios.get("/api/Shop/GetFt",{params:{id:mid}}).then(res=>{
        data.value=res.data;
    })
}

const Updaes=()=>{
    if(data.value.shopName=="")
{
    alert("商铺名称不能为空");
    return;
}
if(data.value.lc=="")
{
    alert("楼层不能为空");
    return;
}
if(data.value.shopId=="")
{
    alert("商铺编号不能为空");
    return;
}
if(data.value.roomMj=="")
{
    alert("室内面积不能为空");
    return;
}
if(data.value.proce==0)
{
    alert("租金不能为空");
    return;
}
if(data.value.phone=="")
{
    alert("联系方式不能为空");
    return;
}
if(data.value.stateId==0)
{
    alert("状态不能为空");
    return;
}
if(data.value.maggess=="")
{
    alert("备注不能为空");
    return;
}
    axios.put("/api/Shop/UpdateShop",data.value).then(res=>{
        if(res.data>0)
    {
        alert("修改成功");
        rout.push({path:"/"})
    }
    else
    {
        alert("修改失败");
    }
    })
}



</script>

<style scoped>

</style>